<template>
	<view>
		<view>
			<view class="top_place">
				<view>{{this.username}}</view>
			</view>
		</view>
		<view style="margin-top: 10px;">
			<!-- <MomentSpace v-for="(item,index) in list" :key="item.id" :imgList="this.photo" :avatar="item.avatar"
				:name="item.id" :publishTime="item.recordTime" :content="item.content" :exerciseTime="item.time"
				:sportName="item.exerciseInfoId" @clickDynamic="clickDynamic(index)" @clickUser="clickUser(item.id)"
				@clickFocus="clickFocus(index)">
			</MomentSpace> -->
			<MomentSpace v-for="(item,index) in list" :key="item.id" :imgList="item.pic.split(',')" :avatar="item.avatar"
				:name="item.exerciseInfoId" :publishTime="item.recordTime" :content="item.content"
				:exerciseTime="item.exerciseTime" :sportName="'运动了'" @clickDynamic="clickDynamic(index)"
				@clickUser="clickUser(item.id)" @clickFocus="clickFocus(index)">
			</MomentSpace>
		</view>
 

	</view>

</template>

<script>
	import MomentSpace from '@/components/MomentSpace.vue'
	export default {
		components: {
			MomentSpace
		},
		data() {
			return {
				partnerid: '',
				username: '',
				list: [
					{
						// content: "string",
						// currentCalories: 0,
						// exerciseInfoId: 5,
						// id: 27,
						// pic: ["https://free-1310941840.cos.ap-shanghai.myqcloud.com/shadow-test/exerciseClockIn/27/1.jpg"],
						// recordTime: "2022-08-17 18:22:56",
						// time: 0,
						// userId: 1,
						// version: 0,
						
						// id: 1,
						// sportName: '跑步',
						// exerciseTime: 30,
						// time: '2022-1-1',
						// content: '打卡打卡打卡呃呃呃呃',
						// pic: ['https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp4.itc.cn%2Fq_70%2Fimages03%2F20210711%2F2d58ef199d614ef6833161670c45c5e0.jpeg&refer=http%3A%2F%2Fp4.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651919216&t=1897c2eb855fa050b3b626b63a78c07e',
						// 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp4.itc.cn%2Fq_70%2Fimages03%2F20210711%2F2d58ef199d614ef6833161670c45c5e0.jpeg&refer=http%3A%2F%2Fp4.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651919216&t=1897c2eb855fa050b3b626b63a78c07e'],
					},
				]
			}
		},
		// 获得用户头像和名称
		onLoad(options) {
			console.log("optioniddddd:")
			console.log(options.id);
			this.setData({
				partnerid: options.id,
			});
			uni.request({
				url: this.$baseUrl + "user?userId=" + this.partnerid,
				method: 'GET',
				header: {
					"session": "shadow-test",
					'Accept': 'application/json',
					"Content-Type": "application/json",
				},
				data: {

				},
				success: res => {
					console.log("username is =")
					console.log(res.data.data.nickname)
					this.username = res.data.data.nickname
				},
				fail: (e) => {
					console.log(e)
				}
			})

			uni.request({
				url: this.$baseUrl + "clockIn/get/exercise/userId=1/page=1",
				method: 'GET',
				header: {
					"session": "shadow-test",
					'Accept': 'application/json',
					"Content-Type": "application/json",
				},
				data: {},
				success: res => {
					console.log(res)
					if (res.statusCode == 200) {
						// console.log("post data:")
						// console.log(res.data)
						// var temp = new String()
						// console.log(res.data.data.exerciseInfoId)
						// var exerid = res.data.data.exerciseInfoId
						// console.log(exerid)
						
						
						this.list = res.data.data
						console.log(this.list)
					} else {
						console.log("广场加载失败")
						uni.showToast({
							title: res.data.errorCode,
							icon: 'error',
						})
					}

				},
				fail: (e) => {
					console.log(e)
				}
			})


		},

		onRefresh() {
			//在当前页面显示导航条加载动画 
			wx.showNavigationBarLoading();
			//显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框 
			wx.showLoading({
				title: '刷新中...',
			})
			this.getData();
		},
		onPullDownRefresh: function() {
			//调用刷新时将执行的方法 
			this.onRefresh();
		},
		methods: {
			clickDynamic(e) {
				console.log('childDynamic');
			},
			// 点击用户信息
			clickUser(e) {
				console.log(e);
				console.log('childUser');
			},
		}
	}
</script>

<style>
	.picture {
		border-radius: 100rpx;
		width: 150rpx;
		height: 150rpx;
		margin-top: 40rpx;
	}

	.top_place {
		text-align: center;
	}

	.content {
		margin-top: 10rpx;
		height: 900rpx;
		background-color: white;
	}
</style>
